<?php


namespace App\Service\RiskCheck;

use App\Constants\XZXResponseCode;
use App\Model\Dao\RiskRuleBanRangeDao;
use App\Model\Dao\RiskRuleBlacktextDao;
use App\Model\Dao\RiskRuleCollectionDao;
use App\Model\Dao\RiskRuleParamDao;
use App\Model\Enum\RiskRuleActionEnum;
use App\Model\Enum\RiskRuleBanRangeTypeEnum;
use App\Model\Enum\RiskRuleBlackTypeEnum;
use App\Model\Enum\RiskRuleProcessTypeEnum;
use App\Utils\CustomUtils;
use App\Utils\RiskCheckUtils;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Arr;

/**
 * Class GlobalRiskCheckService
 * 全局风控
 *
 * @package App\Service\RiskCheck
 */
class GlobalRiskCheckService implements RiskCheckInterface {

    /**
     * @var RiskRuleCollectionDao
     * @Inject()
     */
    protected $RiskRuleCollectionDao;

    public function handle ($params) {

        // 获取规则列表
        $ruleList = $this->RiskRuleCollectionDao->readGlobalRuleList();

        CustomUtils::xzxDebug("全局风控规则列表", $ruleList);

        // 通用风控规则处理
        return ApplicationContext::getContainer()->get(CommonRiskCheckService::class)->handle($params, $ruleList);
    }

    public function clearCache () {
        $this->RiskRuleCollectionDao->clearGlobalRuleList();
    }

}
